
if exists (select 1 from sysobjects where name = 'del_plan' and type = 'P')
begin
   drop procedure del_plan
   print 'Procedure: del_plan deleted ...'
end
go
create procedure del_plan(
  @planid             int           = 1
)
as
begin
  set nocount on

  
  delete from Dienstplan where PlanID = @planid
  delete from Colorplan where PlanID = @planid
  delete from Arbeitszeit where PlanID = @planid
  delete from Terminplan where PlanID = @planid
  delete from Saldoanpassung where PlanID = @planid
  delete from ArbeitsPlanzprs where planID = @planid
  delete from ArbeitsPlan where PlanID = @planid

end
go
print 'Procedure: del_plan done ...'
go
grant exec on del_plan to prsadmins with grant option
go
grant exec on del_plan to prsusers
go

